package com.gupaoedu.vip.mall.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gupaoedu.vip.mall.goods.mapper.CategoryMapper;
import com.gupaoedu.vip.mall.goods.model.Category;
import com.gupaoedu.vip.mall.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分类加载
 */
@Service
public class CategoryServiceImpI extends ServiceImpl<CategoryMapper,Category> implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 根据分类父id查询所有的子分类
     * @param pid
     * @return
     */
    @Override
    public List<Category> findByParentId(Integer pid) {
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();//条件封装对象
        queryWrapper.eq("parent_id",pid);
        return categoryMapper.selectList(queryWrapper);
        //return super.baseMapper.selectList(queryWrapper); 可以不注入CategoryMapper也可调用
    }
}
